package com.weather.projectStart;

import com.weather.MQTT.utils.MqttUtil;
import com.weather.Service.WeatherService;
import com.weather.domain.Weather;
import org.springframework.context.ApplicationContext;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.stereotype.Service;

import javax.annotation.PostConstruct;

/**
 * @author 化粪池堵塞的凶手
 */
@Service
public class ServerStart {
    @PostConstruct
    public void start(){
        /**
         *初始化mqtt
         */
        Logger logger = LogManager.getLogger(LogManager.ROOT_LOGGER_NAME);
        logger.info("MQTT init");
        ClassPathXmlApplicationContext ac = new ClassPathXmlApplicationContext("MqttBeanXml.xml");
        MqttUtil util = (MqttUtil) ac.getBean("mqttUtil");
        util.getConnection();
        util.enableAcceptor();
    }

}
